<?php
/**
 * beimuaihui System
 * Copyright(c) 2011-2020 beimuaihui.
 * @license    http://www.gnu.org/licenses/gpl.html     This software Under GPL V3 License 
 * beimuaihui@gmail.com
 * http://code.google.com/p/beimuaihui/
 * $Id: Rule.php 396 2011-11-11 08:58:55Z beimuaihui@gmail.com $
 */


Zend_Loader::loadClass("Baogg_Db_Table");

//class Permission extends Baogg_Db_Table {
class Rule  extends Baogg_Db_Table {
	/**
	 * The default table name 
	 */
	protected $_name;
	protected $_db ;
	protected $_primary; 
	
	const STUDY_TYPE=1;
	const CMH_TYPE=2;
	
	function __construct() {
		$this->_name =   'rule';
		
		$this->primary= $this->_primary='rule_id';
		parent::__construct();
		
		$this->genFile();
	}
	
	/*
	 *   get  data list
	 */
	

	/*
	 * Get All by state
	 */	
	

	
	

	function getSame($arr) {	
		$ret=array();
		
		$where['rule_name']=$arr['rule_name'];
		return parent::getSame($where);
	   	
	
	}
	
	
	function genFile(){
		$path=BAOGG_UPLOAD_DIR."rule/";
		if(!is_dir($path)){
			mkdir($path,0777,true);
		}
		$rs =$this->getList();
		foreach((array)$rs as $v){
			file_put_contents($path.$v['rule_id'].".php", "<?php
/**
 * beimuaihui System
 * Copyright(c) 2011-2020 beimuaihui.
 * @license    http://www.gnu.org/licenses/gpl.html     This software Under GPL V3 License 
 * beimuaihui@gmail.com
 * http://code.google.com/p/beimuaihui/
 * \$Id: Rule.php 396 2011-11-11 08:58:55Z beimuaihui@gmail.com $
 */\n".$v['compile']."\n?>");
		}
		
	}


}
